<?php
namespace RMD\AccountBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;

use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints as Assert;

class Segment
{
	const ANY = 2;	//OR
	const ALL = 3;	//AND
	private $id;
	private $list_id;
	private $match;	

	protected $conditions;
	protected $list;
	
	public function __construct() {
		$this->conditions = new ArrayCollection();
	}

	public static function loadValidatorMetadata(ClassMetadata $metadata)
    {
		$metadata->addPropertyConstraint('match', new Assert\Choice(array(
            'choices' => array(self::ANY, self::ALL),
            'message' => 'Invalid match type',
        )));
    }
    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set list_id
     *
     * @param integer $listId
     * @return Segment
     */
    public function setListId($listId)
    {
        $this->list_id = $listId;
    
        return $this;
    }

    /**
     * Get list_id
     *
     * @return integer 
     */
    public function getListId()
    {
        return $this->list_id;
    }

    /**
     * Set match
     *
     * @param integer $match
     * @return Segment
     */
    public function setMatch($match)
    {
        $this->match = $match;
    
        return $this;
    }

    /**
     * Get match
     *
     * @return integer 
     */
    public function getMatch()
    {
        return $this->match;
    }

    /**
     * Add conditions
     *
     * @param \RMD\AccountBundle\Entity\Condition $conditions
     * @return Segment
     */
    public function addCondition(\RMD\AccountBundle\Entity\Condition $conditions)
    {
        $this->conditions[] = $conditions;
    
        return $this;
    }

    /**
     * Remove conditions
     *
     * @param \RMD\AccountBundle\Entity\Condition $conditions
     */
    public function removeCondition(\RMD\AccountBundle\Entity\Condition $conditions)
    {
        $this->conditions->removeElement($conditions);
    }

    /**
     * Get conditions
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getConditions()
    {
        return $this->conditions;
    }

    /**
     * Set list
     *
     * @param \RMD\AccountBundle\Entity\Lists $list
     * @return Segment
     */
    public function setList(\RMD\AccountBundle\Entity\Lists $list = null)
    {
        $this->list = $list;
    
        return $this;
    }

    /**
     * Get list
     *
     * @return \RMD\AccountBundle\Entity\Lists 
     */
    public function getList()
    {
        return $this->list;
    }
}